package 笔试题;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 帅小伙
 * @date 2022/1/2
 * @description
 */
public class Demo2022贝壳找房4 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int m = scanner.nextInt();

        int arr[] = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        Arrays.sort(arr);

        int r1 = 0;
        int t = 0;
        for (int i = 0; i < n; i++) {
            if(arr[i]<=m){
                r1+=arr[i];
            }else{
                r1+=arr[n-1];
                break;
            }
        }
        int r2=0;
        for (int i = k; i < n; i++) {
            r2 += arr[i];
        }
        System.out.println(r2);
        System.out.println(Math.max(r1,r2));
    }
}
